package com.bbz.spring;

import com.bbz.spring.bean.Person;
import com.bbz.spring.config.MainConfig2;
import com.bbz.spring.config.MainConfig4;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

public class MainTest4 {
    public static void main(String args[]) {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfig4.class);
        for (String name : applicationContext.getBeanDefinitionNames()) {
            System.out.println(name);
        }
        Person person = (Person) applicationContext.getBean("person");
        System.out.println(person);
        //获取容器运行时的环境变量
        ConfigurableEnvironment environment=applicationContext.getEnvironment();
        System.out.println(environment.getProperty("person.nickName"));

    }
}
